var app = getApp()
Page({
  data: {
    plateId: "",
    orderList: "",
    stateType:"0",
    payMent:'',
    platename:""
  },
  onLoad: function (options) {
    this.setData({
      plateId: options.plateId
    })
  },
  onShow:function(){
    this.showOrderList(this.data.stateType);
  },
  //页面中bindtap传值取值
  showOrder:function(event){
    var _this=this;
    _this.setData({
      stateType: event.currentTarget.dataset.type
    })
    _this.showOrderList(_this.data.stateType)

  },
  showOrderList: function (type) {
    var _this = this;
    app.request({
      url: app.globalData.apiUrl +'/mobileOfficing/api/orderList?pageNum=1&pageSize=10000',
      method: "POST",
      data: {
        plateId: _this.data.plateId,
        type: type
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded',
        "sessionId": wx.getStorageSync(app.globalData.sessionId)
      },
      success: function (res) {
        if (res.data.result) {
          //判断无数据则orderList置空
          if (res.data.data == undefined){
            _this.setData({
              orderList: ''
            })
          }else{
            _this.setData({
              orderList: res.data.data.roomorders,
              platename: res.data.data.plate.name,
            })
          }
          //console.log(_this.data.orderList)
        }
      }
    })
  }

})